# Build recipe for pycairo
#
# Copyright (c) 2018 Markus Tornow, <tornow@riseup.net>.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

program=pycairo
version=1.18.0
release=1

# Set 'outdir' for a nice and well-organized output directory
outdir="${outdir}/${arch}/modules/python"

tarname=${program}-${version}.tar.gz

# Remote source(s)
fetch=http://github.com/pygobject/pycairo/releases/download/v1.18.0/"$tarname"

description="
Pycairo is a Python module providing bindings for the cairo graphics library. 

It depends on cairo >= 1.13.1 and works with Python 2.7+ as well as Python 3.4+. Pycairo, including this documentation, is licensed under the LGPLv2.1 as well as the MPLv1.1.

The Pycairo bindings are designed to match the cairo C API as closely as possible, and to deviate only in cases which are clearly better implemented in a more ‘Pythonic’ way.

Features of the Pycairo bindings:
• Provides an object oriented interface to cairo.
• Queries the error status of objects and translates them to exceptions.
• Provides a C API that can be used by other Python extensions.
"

homepage=http://www.cairographics.org/pycairo/
license="LGPLv2.1+"

docs="COPYING COPYING-LGPL-2.1 COPYING-MPL-1.1 MANIFEST.in PKG-INFO README.rst NEWS"
docsdir="${docdir}/${program}-${version}"

build()
{
    set -e

    unpack "${tardir}/$tarname"

    cd "$srcdir"

    # Set sane permissions
    chmod -R u+w,go-w,a+rX-s .

    # Install for both, Python versions 2 and 3

    for i in 2 3
    do
        python${i} setup.py build
        python${i} setup.py install --prefix=/usr --root="$destdir" --optimize=1
    done
    unset i

    # Copy documentation
    mkdir -p "${destdir}${docsdir}"
    cp -p $docs "${destdir}${docsdir}"
}

